$(function () {
    init()
    function init() {
        title()
        list()
    }
    function title() {
        $.get('http://193.112.55.79:9090/api/getcategorytitle',(res)=>{
        let data =  res.result
        let html = template('sortTitle',data)
        $('.mui-table-view').html(html)
        })
    }
    function list() {
        $('.mui-table-view').on('tap','.tihead',function () {
            let id = parseInt(this.name)
            
            $.ajax({
                url:'http://193.112.55.79:9090/api/getcategory',
                data:{"titleid":id},
                success:(res)=>{
                    console.log(res);    
                    let arr = res.result
                    var html=''
                    for (let i = 0; i < arr.length; i++) {
                    let data = 
                     `<li>
                     <a href="./goods_list.html?categoryId=${arr[i].categoryId}&category=${arr[i].category}">${arr[i].category}</a>
                     
                     </li>`
                        html+=data
                    }
                    
                    $('.sortlist').html(html)
                    
                    
                }
            })
            
        })
    }
})